var express = require('express');
var app = express();
app.listen(8888);

var tweets = [];

app.get('/' , function(request,response){
    res.send("welcome to Node Twitter");    
});

app.post("/send", express.bodyParser(), function(request, response){
    if(request.body && request.body.tweet){
        tweets.push(request.body.tweet);
        response.send({status:"ok", message:"Tweet received"});

    }else{
        response.send({status:"nok", message:"No tweet received"});
    }
});

app.get("/tweets", function(request,response){
    res.send(tweets);
});

console.log("Server is started @8888");
